<%--
  Created by IntelliJ IDEA.
  User: 润
  Date: 2021/7/27
  Time: 10:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#insert").click(function () {
                var cid=document.getElementById("hidden").value;
                var name=document.getElementById("add").value;
                if(name==""){
                    alert("输入内容不能为空！");
                }else {
                    var para= {

                       action:'queryAllGrade',

                       cid:cid

                    };
                    $.ajax({
                        type: "POST",
                        url: "http://localhost:8080/Anyview/GradeServlet?action=addCourse",
                        data: {"name": name,"cid":cid},
                        success: function (data) {
                            if (data.result1) {
                                alert("添加成功！");
                                window.location.href = "http://localhost:8080/Anyview/GradeServlet?"+$.param(para);
                            }
                        },
                        dataType: "json"
                    })


                } })

        })


    </script>
</head>
<body>
<%
   String c= request.getParameter("cid");
   int cid = Integer.parseInt(c);
%>

<div align="center">
    <form >
        请输入年级:<input type="text" id="add" ><br><br>
        <input type="hidden" value="<%=cid%>" id="hidden">
        <input type="button" id="insert" value="确定">
    </form>
</div>
</body>
</html>
